package com.jicheng.mapper;

import com.jicheng.dto.app.*;
import com.jicheng.entity.AppManager;
import com.jicheng.framework.mybatis.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface AppManagerMapper extends BaseMapper<AppManager>   {

    /**
     * 获取app管理列表
     * @param params
     * @return
     */
    List<AppDto> getList(AppPagingParams params);

    /**
     * 获取总数
     * @param params
     * @return
     */
    long getCount(AppPagingParams params);

    /**
     * 获取最新版本号
     * @return
     */
    Map getLastVersion();


    /**
     * 保存用户更新记录
     * @param appHistoryParams
     */
    void saveAppHistory(@Param("appHistoryParams") AppHistoryParams appHistoryParams);

    List<AppUpdateDto> getAppUpdateList(AppPagingParams appPagingParams);

    List<AppHistoryDto> getAppHistoryList(@Param("appId") String appId, @Param("startTime") String startTime, @Param("endTime") String endTime);

    /**
     * 添加监督清单
     * @param params
     */
    @Insert("insert into tb_monitoring_list (business,type,work,work_description,distribution) values (#{params.business},#{params.type},#{params.work},#{params.workDescription},#{params.distribution}) ")
    void addMonitoringList(@Param("params") MonitoringList params);

    /**
     * 获取监督清单列表
     * @param params
     * @return
     */
    List<MonitoringList> getMonitoringList(@Param("params") MonitoringPagingParams params);

    /**
     * 编辑监督清单
     * @param params
     */
    @Update("update tb_monitoring_list set business = #{params.business},type =#{params.type} ,work = #{params.work},work_description = #{params.workDescription},distribution = #{params.distribution} where id = #{params.id}")
    void updateMonitoringList(@Param("params") MonitoringList params);

    /**
     * 删除监督清单
     * @param id
     */
    @Update("update tb_monitoring_list set deleted = 1 where id = #{id}")
    void delMonitoringList(@Param("id") String id);

    @Select("select business,type,work,work_description workDescription,distribution from tb_monitoring_list where id = #{id}")
    MonitoringList checkMonitoringList(@Param("id") String id);

    @Select("select DISTINCT business from tb_monitoring_list")
    List<String> getBusiness();

    @Select("select DISTINCT type from tb_monitoring_list")
    List<String> getType();
}